package com.zxn.event;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.btn_1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "onClick btn_1", Toast.LENGTH_SHORT).show();
            }
        });
        findViewById(R.id.btn_1).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Toast.makeText(MainActivity.this, "onTouch btn_1", Toast.LENGTH_SHORT).show();
                return true;
            }
        });

        findViewById(R.id.btn_2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "onClick btn_2", Toast.LENGTH_SHORT).show();
            }
        });
        findViewById(R.id.btn_2).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Toast.makeText(MainActivity.this, "onTouch btn_2", Toast.LENGTH_SHORT).show();
                return true;
            }
        });

        findViewById(R.id.rl_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "onClick rl_btn", Toast.LENGTH_SHORT).show();
            }
        });
        findViewById(R.id.rl_btn).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Toast.makeText(MainActivity.this, "onTouch rl_btn", Toast.LENGTH_SHORT).show();
                return true;
            }
        });
    }
}